#!/bin/bash
set -euo pipefail

NAME="${TJR_NAME:-tjr}"

# 打印当前运行容器信息（若在运行）
if docker ps --format '{{.Names}}' | grep -Fxq "$NAME"; then
  IMAGE=$(docker inspect -f '{{.Config.Image}}' "$NAME" 2>/dev/null || echo "")
  DIGEST=$(docker image inspect "$IMAGE" --format '{{if .RepoDigests}}{{index .RepoDigests 0}}{{else}}{{.Id}}{{end}}' 2>/dev/null || echo "<unknown>")
  echo "Name: $NAME"
  echo "摘要: $DIGEST"
else
  echo "容器未在运行: $NAME"
fi

docker rm -f "$NAME" || true